const BrowserWindow = require("electron").BrowserWindow
const app = require("electron").app
const IPC = require("electron").ipcMain
const Menu = require("electron").Menu
let mainwin
const MainWindow = ()=>{
     mainwin = new BrowserWindow({
        minWidth:700,
        minHeight:600,
        webPreferences: {
            nodeIntegration:true,
            contextIsolation: false,
            enableRemoteModule: true
        }
    })
    mainwin.loadFile("./index.html").then()
    SetMenu()
}

IPC.on("reload",()=>{
    mainwin.reload()
})

app.whenReady().then(()=>{
    MainWindow()
})

const DataWindow = ()=>{
    const win = new BrowserWindow({
        minWidth:700,
        minHeight:600,
        webPreferences: {
            nodeIntegration:true,
            contextIsolation: false,
            enableRemoteModule: true
        }
    })
    win.loadFile("./DataWindow.html").then()
}

IPC.on("OpenSetData",()=>{
    DataWindow()
})

IPC.on("ERR",(e)=>{
    console.log(e)
})

function SetMenu(){
    const menu = Menu.buildFromTemplate([])
    Menu.setApplicationMenu(menu)
}